

#ifndef UC_RXBOILER_H
#define UC_RXBOILER_H

#include "zAdAChar.h"
#include "zrxnames.h"
#pragma pack (push, 8)


#define UCRX_DECLARE_MEMBERS_EXPIMP(CLASS_NAME, EXPIMP) \
	EXPIMP virtual UcRxClass* isA() const; \
	static UcRxClass* gpDesc; \
	EXPIMP static UcRxClass* desc(); \
	static CLASS_NAME* cast(const UcRxObject* inPtr) \
		{ return ((inPtr == NULL) || !inPtr->isKindOf(CLASS_NAME::desc())) \
		? NULL : (CLASS_NAME*)inPtr; }; \
		static void rxInit(); \
		static void rxInit(AppNameChangeFuncPtr)

#define UCRX_EMPTY

#define UCRX_DECLARE_MEMBERS(CLASS_NAME) \
	UCRX_DECLARE_MEMBERS_EXPIMP(CLASS_NAME, UCRX_EMPTY )


#define UCRX_DEFINE_MEMBERS(CLASS_NAME) \
UcRxClass* CLASS_NAME::desc() \
{ \
    if (CLASS_NAME::gpDesc != NULL) \
        return CLASS_NAME::gpDesc; \
    return CLASS_NAME::gpDesc \
        = (UcRxClass*)((UcRxDictionary*)ucrxSysRegistry() \
        ->at(UCRX_CLASS_DICTIONARY))->at(UCRX_T(#CLASS_NAME)); \
} \
UcRxClass* CLASS_NAME::isA() const \
{ \
    if (CLASS_NAME::gpDesc != NULL) \
        return CLASS_NAME::gpDesc; \
    return CLASS_NAME::gpDesc \
        = (UcRxClass*)((UcRxDictionary*)ucrxSysRegistry() \
        ->at(UCRX_CLASS_DICTIONARY))->at(UCRX_T(#CLASS_NAME)); \
} \
UcRxClass* CLASS_NAME::gpDesc = NULL

#include "zAdAChar.h"

extern "C" void  ucrx_abort (const ZTCHAR * format, ...);
#define UCRX_STATIC_CHECK(CLASS_NAME) \
    if (CLASS_NAME::gpDesc) { \
        UcRxClass *pClass = \
        (UcRxClass*)((UcRxDictionary*)ucrxSysRegistry() \
            ->at(UCRX_CLASS_DICTIONARY))->at(UCRX_T(#CLASS_NAME)); \
        if (pClass) { \
            if (CLASS_NAME::gpDesc == pClass) \
                return; \
            else \
                ucrx_abort(UCRX_T("")); \
        } \
    }

#define UCRX_NO_CONS_DEFINE_MEMBERS(CLASS_NAME,PARENT_CLASS) \
UCRX_DEFINE_MEMBERS(CLASS_NAME); \
void CLASS_NAME::rxInit() { \
    UCRX_STATIC_CHECK(CLASS_NAME); \
    CLASS_NAME::gpDesc = newUcRxClass(UCRX_T(#CLASS_NAME), UCRX_T(#PARENT_CLASS)); \
}

#define UCRX_CONS_DEFINE_MEMBERS(CLASS_NAME,PARENT_CLASS,VERNO) \
UCRX_DEFINE_MEMBERS(CLASS_NAME); \
static UcRxObject * make##CLASS_NAME() { return new CLASS_NAME(); } \
void CLASS_NAME::rxInit() { \
    UCRX_STATIC_CHECK(CLASS_NAME); \
    CLASS_NAME::gpDesc = newUcRxClass(UCRX_T(#CLASS_NAME), UCRX_T(#PARENT_CLASS), \
        VERNO, &make##CLASS_NAME); \
}

#define UCRX_DXF_DEFINE_MEMBERS(CLASS_NAME,PARENT_CLASS,DWG_VERSION,\
              MAINTENANCE_VERSION,PROXY_FLAGS,DXF_NAME,APP) \
UCRX_DEFINE_MEMBERS(CLASS_NAME); \
static UcRxObject * make##CLASS_NAME() { return new CLASS_NAME(); } \
void CLASS_NAME::rxInit() { \
    UCRX_STATIC_CHECK(CLASS_NAME); \
    CLASS_NAME::gpDesc = newUcRxClass(UCRX_T(#CLASS_NAME), UCRX_T(#PARENT_CLASS), \
        DWG_VERSION,MAINTENANCE_VERSION,PROXY_FLAGS, \
        &make##CLASS_NAME, UCRX_T(#DXF_NAME), UCRX_T(#APP)); \
} \
void CLASS_NAME::rxInit(AppNameChangeFuncPtr ptr) { \
    UCRX_STATIC_CHECK(CLASS_NAME); \
    CLASS_NAME::gpDesc = newUcRxClass(UCRX_T(#CLASS_NAME), UCRX_T(#PARENT_CLASS), \
        DWG_VERSION,MAINTENANCE_VERSION,PROXY_FLAGS, \
        &make##CLASS_NAME, UCRX_T(#DXF_NAME), UCRX_T(#APP), ptr); \
}

#pragma pack (pop)
#endif
